<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function html2pdf($html, $filename="quote_template", $stream=TRUE, $size='letter', $orientation='portrait'){
    $CI = & get_instance();
    require_once APPPATH.'libraries/fpdf/concat_pdf.php';
    require_once APPPATH.'libraries/dompdf/dompdf_config.inc.php';
    $dompdf=null;
    $dompdf = new DOMPDF();
    $dompdf->set_paper($size, $orientation);
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf", array('Attachment'=>false));
        return 0;
    } else {
        $file_helper = $CI->load->helper('file');
        write_file(APPPATH."libraries/cache_pdf/$filename.pdf", $dompdf->output());
        return 1;
    }
}